<?php

namespace app\api\controller\supplier;

use app\api\base\RestfulBase;
use app\modules\supplier\logic\SupplierApplyLogic;

Class SupplierApply extends RestfulBase
{
    protected $_open_auth = ['user' => false, 'open_api' => false];
    protected $logic;

    protected function _initialize()
    {

        $this->logic = new SupplierApplyLogic();

    }

    /**
     * 供应商申请
     * @return json
     */
    public function create()
    {
        if ($this->request->isPost()){
            $data['supplier_name'] = $this->getParams('supplier_name', '', 'trim,strip_tags');
            $data['charge'] = $this->getParams('charge', '', 'trim,strip_tags');
            $data['charge_phone'] = $this->getParams('charge_phone', '', 'trim,strip_tags');
            $data['username'] = $this->getParams('username', '', 'trim,strip_tags');
//            $data['password'] = $this->getParams('password', '', 'trim,strip_tags');
            $data['business'] = $this->getParams('business', '', 'trim,strip_tags');
            $data['idcard'] = $this->getParams('idcard', '', 'trim,strip_tags');
            $data['idcard_zp'] = $this->getParams('idcard_zp', '', 'trim,strip_tags');
            $data['idcard_fp'] = $this->getParams('idcard_fp', '', 'trim,strip_tags');
            $data['apply_time'] = time();
            // $data[''] =$this->getParams('','','trim,strip_tags');


            $result = $this->logic->add($data);
            if ($result) {
                return $this->apiSuccess();
            } else {
                return $this->apiError($this->logic->getError());
            }
        }else{
            return $this->apiError('无效请求');
        }

    }

}

